/*    */ package com.qmsk.business.message.customerMessageType.controller;
/*    */ 
/*    */ import com.qmsk.business.message.customerMessageType.dao.CustomerMessageTypeDAO;
/*    */ import com.utils.gson.in.GsonHeadOneRow;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.commons.lang.StringUtils;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"customerMessageType"})
/*    */ public class CustomerMessageTypeController
/*    */ {
/* 26 */   private Logger logger = Logger.getLogger(CustomerMessageTypeController.class);
/*    */ 
/*    */   @Autowired
/*    */   private CustomerMessageTypeDAO dao;
/*    */ 
/*    */   @RequestMapping(value={"list/{openId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getMessageTypelist(HttpServletRequest request, HttpServletResponse response, @PathVariable("openId") String openId)
/*    */   {
/*    */     try {
/* 35 */       String key = RequestUtils.getString(request, "flag");
/* 36 */       GsonEbRst rst = null;
/* 37 */       if (StringUtils.isNotEmpty(key))
/* 38 */         rst = this.dao.getMessageTypeList(openId, Boolean.valueOf(true));
/*    */       else {
/* 40 */         rst = this.dao.getMessageTypeList(openId, Boolean.valueOf(false));
/*    */       }
/* 42 */       ResponseUtils.setResponseResult(rst, response);
/*    */     } catch (Exception e) {
/* 44 */       e.printStackTrace();
/* 45 */       this.logger.error(e);
/* 46 */       ResponseUtils.setErrorMsgResponse(
/* 47 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"unbind/{openId}/{typeId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void unBind(HttpServletRequest request, HttpServletResponse response, @PathVariable("openId") String openId, @PathVariable("typeId") Long typeId)
/*    */   {
/*    */     try
/*    */     {
/* 58 */       if (!(this.dao.checkExisted(openId, typeId).booleanValue())) {
/* 59 */         ResponseUtils.setSuccessResponse(response);
/* 60 */         return;
/*    */       }
/*    */ 
/* 63 */       String[] head = { "openId", "messageTypeId" };
/* 64 */       Object[] list = { openId, typeId };
/* 65 */       GsonHeadOneRow row = new GsonHeadOneRow(head, list);
/* 66 */       int n = this.dao.deleteGsonHeadOneRow(row);
/* 67 */       if (n <= 0) {
/* 68 */         ResponseUtils.setErrorMsgResponse("取消订阅失败！", response);
/* 69 */         DbConnection.rollback();
/* 70 */         return;
/*    */       }
/* 72 */       DbConnection.commit();
/* 73 */       ResponseUtils.setSuccessResponse(response);
/*    */     } catch (Exception e) {
/* 75 */       DbConnection.rollback();
/* 76 */       this.logger.error(e);
/* 77 */       ResponseUtils.setErrorMsgResponse(
/* 78 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"bind/{openId}/{typeId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void bind(HttpServletRequest request, HttpServletResponse response, @PathVariable("openId") String openId, @PathVariable("typeId") Long typeId)
/*    */   {
/*    */     try
/*    */     {
/* 88 */       if (this.dao.checkExisted(openId, typeId).booleanValue()) {
/* 89 */         ResponseUtils.setSuccessResponse(response);
/* 90 */         return;
/*    */       }
/*    */ 
/* 93 */       String[] head = { "openId", "messageTypeId" };
/* 94 */       Object[] list = { openId, typeId };
/* 95 */       GsonHeadOneRow row = new GsonHeadOneRow(head, list);
/* 96 */       int n = this.dao.insertGsonHeadOneRow(row);
/* 97 */       if (n <= 0) {
/* 98 */         ResponseUtils.setErrorMsgResponse("订阅失败！", response);
/* 99 */         DbConnection.rollback();
/* 100 */         return;
/*    */       }
/* 102 */       DbConnection.commit();
/* 103 */       ResponseUtils.setSuccessResponse(response);
/*    */     } catch (Exception e) {
/* 105 */       this.logger.error(e);
/* 106 */       ResponseUtils.setErrorMsgResponse(
/* 107 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.message.customerMessageType.controller.CustomerMessageTypeController
 * JD-Core Version:    0.5.3
 */